{layout name="layout" /}

<div class="Hui-article">
<article class="cl pd-20">
	<form action="" method="post" class="form form-horizontal" id="form-admin-role-add">
		<input type="hidden" name="id" value="{data.id}">
		<div class="row cl">
			<label class="form-label col-xs-2 col-sm-2"><span class="c-red">*</span> 角色名称：</label>
			<div class="formControls col-xs-6 col-sm-2">
				<input type="text" class="input-text" value="{$data.name}" placeholder="" id="role_name" name="role_name" datatype="*4-16">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-2 col-sm-2">管理权限选择：</label>
			<div class="formControls col-xs-6 col-sm-7">
				<dl class="permission-list">
					<dd>
					{foreach $data_permission as $value}
						<dl class="cl permission-list2">
							<dt>
								<label>
									<input type="checkbox" class="parent" value="{$value.id}" name="check[]" id="check_{$value.id}" 
										{if condition="in_array($value.id, $role_powers)"}checked{/if}>
									{$value.name}
								</label>
								<dd>
									{notempty name='value.child'}
									{foreach $value.child as $val}
									<label>
										<input type="checkbox" class="child pid_{$val.pid}" data-pid="{$val.pid}" value="{$val.id}" name="check[]"
											{if condition="in_array($val.id, $role_powers)"}checked{/if} id="check_{$val.id}">
										{$val.name}
									</label>
									{/foreach}
									{/notempty}
								</dd>
							</dt>
						</dl>
					{/foreach}
					</dd>
				</dl>
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-2">备注：</label>
			<div class="formControls col-xs-8 col-sm-7">
				<textarea id="description" name="description" cols="" rows="" class="textarea" placeholder="备注...200个字符以内" dragonfly="true"
					onKeyUp="textarealength(this,200)">{$data.description}</textarea>
				<p class="textarea-numberbar">
					<em class="textarea-length">0</em>/200</p>
			</div>
			</div>
		<div class="row cl">
			<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
				<button type="submit" class="btn btn-success radius" id="admin-role-save" name=""><i class="Hui-iconfont">&#xe632;</i>&nbsp;确&nbsp;定&nbsp;</button>
				<button type="button" class="btn btn-default radius" onClick="window.history.back();"><i class="Hui-iconfont">&#xe66b;</i>&nbsp;取&nbsp;消&nbsp;</button>
			</div>
		</div>
	</form>
</article>
</div>

<!--请在下方写此页面业务相关的脚本--> 
<script type="text/javascript">
$(function(){
	$(".child").click(function(){
		var pid = $(this).data('pid');

		$("#check_"+pid).prop('checked', true);
	})

	$(".parent").click(function(){
		var id = $(this).val();
		var status = $(this).prop('checked');

		if (status) {
			$(".pid_"+id).prop('checked', !$(".pid_"+id).prop('checked'));
		} else {
			$(".pid_"+id).prop('checked', false);
		}		
	})
})
</script>
<!--请在上方写此页面业务相关的脚本-->